package com.corejava.training.collections.car.pre15.immutable;

import java.util.*;

public class TelevisionImmutableDemo {

	/**
	 * @param args
	 */
	public static void main(String[] args) {

		//instantiate the class with difference instances
		
		TelevisionImmutable tv1 = new TelevisionImmutable("Sony","LCD", false, 299.99);
		TelevisionImmutable tv2 = new TelevisionImmutable("Samsung","LED", true, 399.99);
		TelevisionImmutable tv3 = new TelevisionImmutable("Sharp","Plasma", true, 699.99);
		
		// create a list and add tv objects to it
		
		List tvs = new ArrayList();
		tvs.add(tv1);
		tvs.add(tv2);
		tvs.add(tv3);
		
		// read from list and print out in java 1.4 style
		Iterator ite = tvs.iterator();
		while(ite.hasNext()){
			TelevisionImmutable tvm = (TelevisionImmutable) ite.next();
			System.out.println("Company: " + tvm.getCompany());
			System.out.println("Type: " + tvm.getType());
			System.out.println("3D enabled: " + tvm.isThreedenabled());
			System.out.println("Price: " + tvm.getPrice());
			System.out.println("---------------------------------"); 
			
		}
		
		// jdk 1.5 style
		List<TelevisionImmutable> tvi = new ArrayList<TelevisionImmutable>();
		tvi.add(tv1);
		tvi.add(tv2);
		tvi.add(tv3);
		
		// read from the list and print out 
		for(TelevisionImmutable immutv : tvi){
			System.out.println("START PRINT WITH JDK 1.5");
			System.out.println("Company: " + immutv.getCompany());
			System.out.println("Type: " + immutv.getType());
			System.out.println("3D enabled: " + immutv.isThreedenabled());
			System.out.println("Price: " + immutv.getPrice());
			System.out.println("---------------------------------");
			
		}
		
		
	}

}
